import java.util.TreeMap;

import com.bootdo.common.utils.HttpUtil;
import com.bootdo.common.wx.WxConstants;
import com.bootdo.system.domain.WechatTemplate;

import net.sf.json.JSONObject;

public class cnmsdfsd {
	
	//微信模板接口
		 private final String SEND_TEMPLATE_MESSAGE_URL = "https://api.weixin.qq.com/cgi-bin/message/template/send";
		 //模板消息详情跳转URL
		 public  String sendWxMsg(String text,String tblx,String tbsj,String openId,String code,String accessToken) {
		   TreeMap<String, TreeMap<String, String>> params = new TreeMap<String, TreeMap<String, String>>();
		   params.put("first", WechatTemplate.item("标注项目竞标信息", "#000000"));
		   params.put("keyword1", WechatTemplate.item(text, "#000000"));
		   params.put("keyword2", WechatTemplate.item(tblx, "#000000"));
		   params.put("keyword3", WechatTemplate.item(tbsj, "#000000"));
		   params.put("remark", WechatTemplate.item("想要竞标项目的小伙伴，请尽快参与吧！", "#000000"));
		   WechatTemplate wechatTemplate = new WechatTemplate();
		   wechatTemplate.setTemplate_id(WxConstants.TEMPLATEID);
		   wechatTemplate.setTouser(openId);
		   wechatTemplate.setData(params);
		   JSONObject json = JSONObject.fromObject(wechatTemplate);//将java对象转换为json对象
		   String sendData = json.toString();//将json对象转换为字符串
		  
		   TreeMap<String, String> treeMap = new TreeMap<String, String>();
		   treeMap.put("access_token", accessToken);
		   String retInfo = HttpUtil.doPost(SEND_TEMPLATE_MESSAGE_URL, treeMap, sendData);
		   return retInfo;
		 }

}
